package com.tdk.bts.view;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.tdk.bts.util.ImageUtil;

public class IndexView {

	private JFrame jf;
	
	private FilmListView filmListView; 
	
	private JLabel preLabel;
	
	private JLabel nextLabel;
	
	public void show()
	{
		init();
		setStyle();
		registHandler();
		jf.setVisible(true);
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	private void init() {
		jf = new JFrame();
		filmListView = new FilmListView(jf);
		preLabel = new JLabel();
		nextLabel = new JLabel();
	}

	private void setStyle() {
		jf.setSize(400, 700);
		jf.setLocationRelativeTo(null);
		jf.setLayout(null);
		jf.add(filmListView);
		
		
		preLabel.setIcon(ImageUtil.getImage("pre.png"));
		preLabel.setBounds(20, 600, 100, 50);
		jf.add(preLabel);
		preLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
		
		nextLabel.setIcon(ImageUtil.getImage("next.png"));
		nextLabel.setBounds(280, 600, 100, 50);
		jf.add(nextLabel);
		nextLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
		
	}
	private void registHandler() {
		preLabel.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				filmListView.prePage();
			}
		});
		
		nextLabel.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				filmListView.nextPage();
			}
		});
		
	}
	public static void main(String[] args) {
		new IndexView().show();
	}
	
	
}
